//系统方案

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

int main(){
  //C库
  fprintf(stdout, "hello fprintf\n");
  //系统调用
  const char* msg = "hello write\n";
  write(1, msg, strlen(msg));

  //??
  fork();

  return 0;
}

//#define LOG_NORMAL "logNormal.txt"
//#define LOG_ERROR "logError.txt"
//
//int main(){
//
//  int fd = open(LOG_NORMAL, O_CREAT | O_WRONLY | O_APPEND, 0666);
//  if (fd < 0){
//    perror("open");
//    return 1;
//  }
//
//  dup2(fd, 1);
//  printf("hello world, hello cxk!\n");
//  close(fd);
//
//
//  //close(1);
//  //open(LOG_NORMAL, O_WRONLY | O_CREAT | O_APPEND, 0666);
//
//  //close(2);
//  //open(LOG_ERROR, O_WRONLY | O_CREAT | O_APPEND, 0666);
//
//  //printf("hello printf->stdout\n");
//  //printf("hello printf->stdout\n");
//  //printf("hello printf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//  //fprintf(stdout, "hello fprintf->stdout\n");
//
//  //fprintf(stderr, "hello fprintf->stderr\n");
//  //fprintf(stderr, "hello fprintf->stderr\n");
//  //fprintf(stderr, "hello fprintf->stderr\n");
//  //fprintf(stderr, "hello fprintf->stderr\n");
//  //fprintf(stderr, "hello fprintf->stderr\n");
//
//  //printf("%d\n", stdin->_fileno);
//  //printf("%d\n", stdout->_fileno);
//  //printf("%d\n", stderr->_fileno);
//
//  //FILE* fp = fopen(LOG, "w");
//  //printf("%d\n", fp->_fileno);
//  
////  umask(0);
////  //fclose(stdin);//close(0)
////  
////  //close(0);
////  //close(2);
////  //close(0);
////  //int fd = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  //int fd = open(LOG, O_RDONLY);
////  close(1);
////  int fd = open(LOG, O_WRONLY | O_CREAT | O_APPEND, 0666);
////
////  //int a, b;
////  //scanf("%d %d", &a, &b);
////
////  //printf("a = %d, b = %d\n", a, b);
////  
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////  printf("you can see me!\n");
////
////  int fd1 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  int fd2 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  int fd3 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  int fd4 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  int fd5 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////  int fd6 = open(LOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
////
////  printf("%d\n", fd1);
////  printf("%d\n", fd2);
////  printf("%d\n", fd3);
////  printf("%d\n", fd4);
////  printf("%d\n", fd5);
////  printf("%d\n", fd6);
////
//  return 0;
//}

